public class Solution1453 {
    public int numPoints(int[][] darts, int r) {
        int max=1;
        for (int i=0;i<darts.length;i++){
            for (int j=i+1;j<darts.length;j++){
                double[] center=cal1(darts[i],darts[j],r);
                int now=0;
                for (int[] dart : darts) {
                    if (dis(dart[0],dart[1],center[0],center[1]) < r + 0.00001) {
                        now++;
                    }
                }
                max=Math.max(max,now);
                center=cal2(darts[i],darts[j],r);
                now=0;
                for (int[] dart : darts) {
                    if (dis(dart[0],dart[1],center[0],center[1]) < r + 0.00001) {
                        now++;
                    }
                }
                max=Math.max(max,now);
            }
        }
        return max;
    }

    private double[] cal2(int[] a, int[] b, int r) {
        double[] mid={(a[0]+b[0])*1.0/2,(a[1]+b[1])*1.0/2};
        double h=Math.sqrt(r*r-dis(a[0],a[1],b[0],b[1])*dis(a[0],a[1],b[0],b[1])/4);
        double[] vector={(b[1]-a[1])/dis(a[0],a[1],b[0],b[1]),(a[0]-b[0])/dis(a[0],a[1],b[0],b[1])};
        return new double[]{mid[0]-h*vector[0],mid[1]-h*vector[1]};
    }

    private double[] cal1(int[] a, int[] b, int r) {
        double[] mid={(a[0]+b[0])*1.0/2,(a[1]+b[1])*1.0/2};
        double h=Math.sqrt(r*r-dis(a[0],a[1],b[0],b[1])*dis(a[0],a[1],b[0],b[1])/4);
        double[] vector={(b[1]-a[1])/dis(a[0],a[1],b[0],b[1]),(a[0]-b[0])/dis(a[0],a[1],b[0],b[1])};
        return new double[]{mid[0]+h*vector[0],mid[1]+h*vector[1]};
    }

    private double dis(double a0,double a1,double b0,double b1) {
        return Math.sqrt((a0-b0)*(a0-b0)+(a1-b1)*(a1-b1));
    }

    public static void main(String[] args) {
        System.out.println(new Solution1453().numPoints(new int[][]{{-2,0},{2,0},{0,2},{0,-2}},2));
    }
}
